//1. 安装路由
// 2. 导入路由
import VueRouter from 'vue-router'
//3. 注册路由
import Vue from 'vue'
Vue.use(VueRouter)
// 导入组件
import find from '../views/find.vue'
import newMusic from '../views/newMusic.vue'
import newMv from '../views/newMv.vue'
import audioPlay from '../views/audioPlay.vue'
import mvPlay from '../views/mvPlay.vue'
// 4. 路由实例化
const router = new VueRouter({
    routes:[
        {
          path:'/',
          redirect:find
        },
        {
          path:'/find',
          component:find
        },
        {
          path:'/newMusic',
          component:newMusic
        },
        {
          path:'/newMv',
          component:newMv
        },
        {
          path:'/audioPlay',
          component:audioPlay
        },
        {
          path:'/mvPlay',
          component:mvPlay
        },
        {
            path:'*',
            redirect:"/find"
          },
      ]
})
// 解决同一路由重复点击出现的BUG
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
// 暴露路由实例对象 在入口js  main.js中接收
export default router
